﻿using Abp.Dependency;
using Abp.Runtime.Session;
using Paas.App.Interface.Approvals.Dtos;
using Basefr.App.Dtos;
using Basefr.Core.Consts.Enums;
using Basefr.Runtime.Extensions;
using System.Linq;

namespace Paas.App.Interface
{
    public class ApproveDtoBase : DtoBase
    {
        public EnumApproveState ApproveState { get; set; }
        public string ApproveStateStr => ApproveState.Description();

        /// <summary>
        /// 审批记录
        /// </summary>
        public ApproveDto Approve { get; set; }

        /// <summary>
        /// 当前用户是否流程发起人
        /// </summary>
        public bool IsApplicant => Approve?.Steps.OrderBy(p => p.SortIndex).First().OperatorId == IocManager.Instance.Resolve<IAbpSession>().GetUserId();

        /// <summary>
        /// 当前用户是否执行人
        /// </summary>
        public bool IsCurrentOperator => Approve?.Steps.Any(s => s.IsCurrent && s.IsStepOperator) ?? false;

    }
}

